{% extends "base/front.html" %}

{% block title %}首页{% endblock %}

{% block head %}
<style type="text/css">
    /*
    .carousel{
     background-color: #000000;
    }
    .carousel .item{
     max-height: 360px;
     background-color: #000000;
    }
    */
    .carousel img{
     height: 320px;
     //width: 100%;
    }
blockquote {
    display: block;
    border-left: 8px solid #d0e5f2;
    padding: 5px 10px;
    margin: 10px 0;
    line-height: 1.4;
    font-size: 100%;
    background-color: #f1f1f1;
}
</style>
{% endblock %}

{% block notice %}
            <marquee direction="left" scrollamount="5" bgcolor="#FFFFFF">
                {% for notice in g.api.get_sys_notice().data %}
                <i class="icon-bullhorn"></i>&nbsp;{{ notice.msg|safe }}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                {% endfor %}
            </marquee>
{% endblock %}

{% block PathNavigation %}
			<ul class="breadcrumb">
				<li class="active">
					当前位置：<a href="{{ url_for('front.index') }}">首页</a>
				</li>
			</ul>
{% endblock %}

{% block AlternateDiagram %}
            {%- set banners = g.api.get_banner().data %}
            <div class="carousel slide" id="carousel-394119">
                <ol class="carousel-indicators">
                    {%- for banner in banners %}
                    <li data-slide-to="{{ loop.index0 }}" data-target="#carousel-394119"{% if banner.isActive %} class="active"{% endif %}></li>
                    {%- endfor %}
                </ol>
                <div class="carousel-inner">
                    {%- for banner in banners %}
                    <div class="item{% if banner.isActive %} active{% endif %}">
                        <a href="{{ url_for('front.blogShow', bid=banner.id) }}"><img src="{{ banner.imgUrl }}" width="1600px" height="320px"  /></a>
                        <div class="carousel-caption">
                            <p>{{ banner.title }}</p>
                        </div>
                    </div>
                    {%- endfor %}
                </div>
                <a class="left carousel-control" href="#carousel-394119" data-slide="prev">
                    <span class="glyphicon glyphicon-chevron-left"></span>
                </a>
                <a class="right carousel-control" href="#carousel-394119" data-slide="next">
                    <span class="glyphicon glyphicon-chevron-right"></span>
                </a>
            </div>
{% endblock %}

{% block container %}
            <!-- 置顶文章列表 -->
            <div class="row clearfix">
                <div class="col-md-12 column">
                    <h3>置顶文章</h3>
                    <ul class="list-unstyled">
                    {% for blog in g.api.blog_get_top_data().data %}
                        <li><a href="{{ url_for('front.blogShow', bid=blog.id) }}">{{ blog.title }}</a></li>
                    {% endfor %}
                    </ul>
                </div>
            </div>
            <!-- 文章列表缩略 -->
            <h3>最新文章</h3>
            {% set blogs = g.api.blog_get_single_index(page=request.args.get("page", 0), length=request.args.get("length", 8)) %}
            {% if blogs.data %}
            <blockquote>
            {% for blog in blogs.data %}
			<div class="row clearfix">
				<div class="col-md-12 column">
					<h4 class="text-left text-success">
						<a href="{{ url_for('front.blogShow', bid=blog.id) }}" style="color: blue; font-weight: bold;">{{ blog.title }}</a>
					</h4>
					<h5>
					    {#
					    <small><i class="icon-user icon-1x"></i><a href="{{ url_for('front.userGo', uid=blog.author) }}" style="color: #999">&nbsp;作者主页</a>&nbsp;</small>
					    #}

                        {% if blog.catalog %}
					    <small><i class="icon-folder-open icon-1x"></i><a href="{{ url_for('front.blogResource', resource_type='catalog', resource_data=blog.catalog) }}" title="查看 {{ blog.catalog }} 分类中所有文章" style="color: #999">&nbsp;{{ blog.catalog }}</a>&nbsp;</small>
					    {% endif %}

                        {% if blog.tag %}
					    <small><i class="icon-tag icon-1x"></i>
					    {% for tag in blog.tag.split() %}
					        <a href="{{ url_for('front.blogResource', resource_type='tag', resource_data=tag) }}" title="查看 {{ tag }} 标签中所有文章" style="color: #999">{{ tag }}</a>&nbsp;
					    {% endfor %}
					    </small>
					    {% endif %}

                        {% if blog.create_time %}
					    <small><i class="icon-calendar icon-1x"></i><scan style="color: #999">&nbsp;{{ blog.create_time }}</scan>&nbsp;</small>
					    {% endif %}

                        {{ emit_tep('blog_index_infolist', blog=blog) }}
					</h5>
				</div>
			</div>
			{% endfor %}
			<!-- 分页 -->
			{%- set prev = blogs.page.page - 1 %}
			{%- set next = blogs.page.page + 1 %}
			{%- set last = blogs.page.PageCount - 1 %}
			<nav aria-label="">
            <center>
			<ul class="pagination">
			    {%- if blogs.page.page == 0 %}
				<li class="disabled"><a>Prev</a></li>
				{% else -%}
				<li><a href="{{ url_for('front.index', page=prev) }}">Prev</a></li>
				{% endif -%}
				{%- for p in range(blogs.page.PageCount) %}
				    {%- if blogs.page.page == p -%}
				        <li class="disabled"><a>{{ p }}</a></li>
				    {%- else -%}
				        <li><a href="{{ url_for('front.index', page=p) }}">{{ p }}</a></li>
				    {% endif -%}
                {% endfor -%}
			    {% if blogs.page.page == last %}
				<li class="disabled"><a>Next</a></li>
				{% else %}
				<li><a href="{{ url_for('front.index', page=next) }}">Next</a></li>
				{%- endif %}
			</ul>
			</center>
			</nav>
			</blockquote>
            {% endif %}
{% endblock %}

